package swu.cx.androidmvc

import swu.cx.androidmvc.Model.Book
import swu.cx.androidmvc.Utils.BookProviderFactory
import swu.cx.androidmvc.ui.IBookPresenter
import swu.cx.androidmvc.ui.IBookView

class BookPresenter:IBookPresenter {
    var bookView:IBookView?=null
    val repository = BookProviderFactory.getBookRepository()
    override fun checkInput(content1: String, content2: String) {
        if (content1.isEmpty()||content2.isEmpty()){
            bookView?.inputIsValid(false)
        }else{
            bookView?.inputIsValid(true)
        }
    }
    override fun addBook(book: Book) {
        repository.addBook(book)
        bookView?.showBooks(repository.getBooks())
    }
}